package com.ciccwm.auth.config;

import com.ciccwm.auth.util.JwtTokenUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.security.oauth2.jwt.JwtClaimsSet;
import org.springframework.security.oauth2.server.authorization.token.JwtEncodingContext;
import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenCustomizer;
import org.springframework.stereotype.Component;

/**
 * 自定义令牌增强器.
 */
@Component
@RequiredArgsConstructor
public class CustomTokenEnhancer implements OAuth2TokenCustomizer<JwtEncodingContext> {

    private final JwtTokenUtil jwtTokenUtil;

    @Override
    public void customize(JwtEncodingContext context) {
        JwtClaimsSet.Builder claims = context.getClaims();
        
        // 添加自定义声明
        claims.claim("custom_claim", "custom_value");
        
        // 如果需要，可以添加更多自定义声明
        // claims.claim("user_id", getUserId());
        // claims.claim("username", getUsername());
    }
} 
